ソースコード
#coding:utf-8
#function 関数
#python 内蔵関数 built functionの利用
#既存モジュール
import os
os.system('clear')
import random
x = random.randint(2,20)
print (f'この乱数は{x:2g}')
import math
d = int(input('何度ですか? '))
a = math.radians(d)
print (f'cos({d})={math.cos(a):5.2f}')
#自己定義関数の作成と呼出し
#あるあいさつ文を出力する、その出力回数を引数とする
#関数の定義 definition
def hello(name):
print (f'Hello {name}!')
def hello_1():
name =input('名前: ')
print (f'Hello {name}!')
def multi_hello(x,y):
for i in range(x):
hello(y)
def multi_hello_2(x):
for i in range(x):
hello_1()
#関数の呼出し実行 call and excute
name =input('名前: ')
x = int(input("何回する? "))
multi_hello(x,name)
x = int(input("何回する? "))
multi_hello_2(x)